import { Component, OnInit } from '@angular/core';
import {NzModalRef} from "ng-zorro-antd/modal";
import {CustomLoginForm} from "../../../../to/CustomLoginForm";
import {AlertService} from "../../../../services/alert.service";
import {CustomService} from "../../../../services/custom.service";

@Component({
  selector: 'app-adminlogin',
  templateUrl: './adminlogin.component.html',
  styleUrls: ['./adminlogin.component.css']
})
export class AdminloginComponent implements OnInit {
   f:CustomLoginForm;
  constructor(private modal: NzModalRef,
      private alertservice:AlertService
              ,private customservice:CustomService
              ) {
    this.f=new CustomLoginForm();
  }

  ngOnInit(): void {

  }



    login(){
    this.customservice.gererateAdminToken(this.f)
      .then((data:any)=>{
        if(data.msg=='ok'){
          this.customservice.userid=this.f.cell;
          this.customservice.token=data.obj;
        this.modal.close('ok');
        }
        else {
          this.modal.close('error');
        }
      })
    }

}
